const defaultState = {
    inputValue: 'writer holllo自己',
    list: [
        '自己添加内容1',
        '自己添加内容2',
        '自己添加内容3'
    ]
}
export default (state=defaultState,actions) => {
    // console.log(state,actions) //state：旧的值 actions:新的值
    //reducer里面只能接受 state 不能改变
    if(actions.type==='changeinput'){
        let newState=JSON.parse(JSON.stringify(state))
        newState.inputValue=actions.value
        return newState
    }
    if(actions.type==='setitemvalue'){
        let newState=JSON.parse(JSON.stringify(state))
        // console.log(newState.inputValue) writer holllo自己
        newState.list.push(newState.inputValue)
        newState.inputValue=''

        return newState
    }
    if(actions.type==='deleteinputValue',actions){
        let newState=JSON.parse(JSON.stringify(state))
    //   console.log(actions.index)  0 1 2
        newState.list.splice(actions.index,1)
        return newState
    }
    return state
}